package cn.cjxy.web.session;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author huangjie
 * @date 2025/9/27
 */
@WebServlet("/query")
public class SessionQuery extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=utf-8");
        //得到session中的对象
        Person person = (Person)req.getSession().getAttribute("person");
        PrintWriter writer = resp.getWriter();
        writer.println("query访问成功....会话id"+req.getSession().getId());
        writer.print(person);

    }
}
